home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / elispman.lha / elispman / elisp-20 (.txt) < prev    next >
GNU Info File  |  1993-06-01  |  51KB  |  927 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  4. Emacs Version 19.
  5.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  6. Cambridge, MA 02139 USA
  7.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided that
  13. the entire resulting derived work is distributed under the terms of a
  14. permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that this permission notice may be stated in a
  18. translation approved by the Foundation.
  19. File: elisp,  Node: Deleting Windows,  Next: Selecting Windows,  Prev: Splitting Windows,  Up: Windows
  20. Deleting Windows
  21. ================
  22.    A window remains visible on its frame unless you "delete" it by
  23. calling certain functions that delete windows.  A deleted window cannot
  24. appear on the screen, but continues to exist as a Lisp object until
  25. there are no references to it.  There is no way to cancel the deletion
  26. of a window aside from restoring a saved window configuration (*note
  27. Window Configurations::.).  Restoring a window configuration also
  28. deletes any windows that aren't part of that configuration.
  29.    When you delete a window, the space it took up is given to one
  30. adjacent sibling.  (In Emacs version 18, the space was divided evenly
  31. among all the siblings.)
  32.  - Function: window-live-p WINDOW
  33.      This function returns `nil' if WINDOW is deleted, and `t'
  34.      otherwise.
  35.      *Warning:* erroneous information or fatal errors may result from
  36.      using a deleted window as if it were live.
  37.  - Command: delete-window &optional WINDOW
  38.      This function removes WINDOW from the display.  If WINDOW is
  39.      omitted, then the selected window is deleted.  An error is signaled
  40.      if there is only one window when `delete-window' is called.
  41.      This function returns `nil'.
  42.      When `delete-window' is called interactively, WINDOW defaults to
  43.      the selected window.
  44.  - Command: delete-other-windows &optional WINDOW
  45.      This function makes WINDOW the only window on its frame, by
  46.      deleting all the other windows.  If WINDOW is omitted or `nil',
  47.      then the selected window is used by default.
  48.      The result is `nil'.
  49.  - Command: delete-windows-on BUFFER
  50.      This function deletes all windows showing BUFFER.  If there are no
  51.      windows showing BUFFER, then this function does nothing.  If all
  52.      windows in some frame are showing BUFFER (including the case where
  53.      there is only one window), then the frame reverts to having a
  54.      single window showing the buffer chosen by `other-buffer'.  *Note
  55.      The Buffer List::.
  56.      If there are several windows showing different buffers, then those
  57.      showing BUFFER are removed, and the others are expanded to fill the
  58.      void.
  59.      The result is `nil'.
  60. File: elisp,  Node: Selecting Windows,  Next: Cyclic Window Ordering,  Prev: Deleting Windows,  Up: Windows
  61. Selecting Windows
  62. =================
  63.    When a window is selected, the buffer in the window becomes the
  64. current buffer, and the cursor will appear in it.
  65.  - Function: selected-window
  66.      This function returns the selected window.  This is the window in
  67.      which the cursor appears and to which many commands apply.
  68.  - Function: select-window WINDOW
  69.      This function makes WINDOW the selected window.  The cursor then
  70.      appears in WINDOW (on redisplay).  The buffer being displayed in
  71.      WINDOW is immediately designated the current buffer.
  72.      The return value is WINDOW.
  73.           (setq w (next-window))
  74.           (select-window w)
  75.                => #<window 65 on windows.texi>
  76.    The following functions choose one of the windows on the screen,
  77. offering various criteria for the choice.
  78.  - Function: get-lru-window &optional ALL-FRAMES
  79.      This function returns the window least recently "used" (that is,
  80.      selected).  The selected window is always the most recently used
  81.      window.
  82.      The selected window can be the least recently used window if it is
  83.      the only window.  A newly created window becomes the least
  84.      recently used window until it is selected.  The minibuffer window
  85.      is not considered a candidate.
  86.      The argument ALL-FRAMES controls which set of windows are
  87.      considered.  If it is non-`nil', then all windows on all frames are
  88.      considered.  Otherwise, only windows in the selected frame are
  89.      considered.
  90.  - Function: get-largest-window &optional ALL-FRAMES
  91.      This function returns the window with the largest area (height
  92.      times width).  If there are no side-by-side windows, then this is
  93.      the window with the most lines.  The minibuffer window is not
  94.      considered a candidate.
  95.      If there are two windows of the same size, then the function
  96.      returns the window which is first in the cyclic ordering of
  97.      windows (see following section), starting from the selected window.
  98.      The argument ALL-FRAMES controls which set of windows are
  99.      considered.  If it is non-`nil', then all windows on all frames are
  100.      considered.  Otherwise, only windows in the selected frame are
  101.      considered.
  102. File: elisp,  Node: Cyclic Window Ordering,  Next: Buffers and Windows,  Prev: Selecting Windows,  Up: Windows
  103. Cycling Ordering of Windows
  104. ===========================
  105.    When you use the command `C-x o' (`other-window') to select the next
  106. window, it moves through all the windows on the screen in a specific
  107. cyclic order.  For any given configuration of windows, this order never
  108. varies.  It is called the "cyclic ordering of windows".
  109.    This ordering generally goes from top to bottom, and from left to
  110. right.  But it may go down first or go right first, depending on the
  111. order in which the windows were split.
  112.    If the first split was vertical (into windows one above each other),
  113. and then the subwindows were split horizontally, then the ordering is
  114. left to right in the top, and then left to right in the next lower part
  115. of the frame, and so on.  If the first split was horizontal, the
  116. ordering is top to bottom in the left part, and so on.  In general,
  117. within each set of siblings at any level in the window tree, the order
  118. is left to right, or top to bottom.
  119.  - Function: next-window WINDOW &optional MINIBUF ALL-FRAMES
  120.      This function returns the window following WINDOW in the cyclic
  121.      ordering of windows.  This is the window which `C-x o' would select
  122.      if done when WINDOW is selected.  If WINDOW is the only window
  123.      visible, then this function returns WINDOW.
  124.      The value of the argument MINIBUF determines whether the
  125.      minibuffer is included in the window order.  Normally, when
  126.      MINIBUF is `nil', the minibuffer is included if it is currently
  127.      active; this is the behavior of `C-x o'.
  128.      If MINIBUF is `t', then the cyclic ordering includes the
  129.      minibuffer window even if it is not active.
  130.      If MINIBUF is neither `t' nor `nil', then the minibuffer window is
  131.      not included even if it is active.  (The minibuffer window is
  132.      active while the minibuffer is in use.  *Note Minibuffers::.)
  133.      When there are multiple frames, this functions normally cycles
  134.      through all the windows in the selected frame, plus the minibuffer
  135.      used by the selected frame even if it lies in some other frame.
  136.      If ALL-FRAMES is `t', then it cycles through all the windows in
  137.      all the frames that currently exist.
  138.      If ALL-FRAMES is neither `t' nor `nil', then it cycles through
  139.      precisely the windows in the selected frame, excluding the
  140.      minibuffer in use if it lies in some other frame.
  141.      This example shows two windows, which both happen to be displaying
  142.      the same buffer:
  143.           (selected-window)
  144.                => #<window 56 on windows.texi>
  145.           (next-window (selected-window))
  146.                => #<window 52 on windows.texi>
  147.           (next-window (next-window (selected-window)))
  148.                => #<window 56 on windows.texi>
  149.  - Function: previous-window WINDOW &optional MINIBUF ALL-FRAMES
  150.      This function returns the window preceding WINDOW in the cyclic
  151.      ordering of windows.  The other arguments affect which windows are
  152.      included in the cycle, as in `next-window'.
  153.  - Command: other-window COUNT
  154.      This function selects the COUNTth next window in the cyclic order.
  155.      If count is negative, then it selects the -COUNTth preceding
  156.      window.  It returns `nil'.
  157.      In an interactive call, COUNT is the numeric prefix argument.
  158.  - Function: walk-windows PROC &optional MINIBUF ALL-FRAMES
  159.      This function cycles through all visible windows, calling `proc'
  160.      once for each window with the window as its sole argument.
  161.      The optional argument MINIBUF says whether to include minibuffer
  162.      windows.  A value of `t' means count the minibuffer window even if
  163.      not active.  A value of `nil' means count it only if active.  Any
  164.      other value means not to count the minibuffer even if it is active.
  165.      If the optional third argument ALL-FRAMES is `t', that means
  166.      include all windows in all frames.  If ALL-FRAMES is `nil', it
  167.      means to cycle within the selected frame, but include the
  168.      minibuffer window (if MINIBUF says so) that that frame uses, even
  169.      if it is on another frame.  If ALL-FRAMES is neither `nil' nor `t',
  170.      `walk-windows' sticks strictly to the selected frame.
  171. File: elisp,  Node: Buffers and Windows,  Next: Displaying Buffers,  Prev: Cyclic Window Ordering,  Up: Windows
  172. Buffers and Windows
  173. ===================
  174.    This section describes low-level functions to examine windows or to
  175. show buffers in windows in a precisely controlled fashion.  *Note
  176. Displaying Buffers::, for related functions that find a window to use
  177. and specify a buffer for it.  The functions described there are easier
  178. to use than these, but they employ heuristics in choosing or creating a
  179. window; use these functions when you need complete control.
  180.  - Function: set-window-buffer WINDOW BUFFER-OR-NAME
  181.      This function makes WINDOW display BUFFER-OR-NAME as its contents.
  182.      It returns `nil'.
  183.           (set-window-buffer (selected-window) "foo")
  184.                => nil
  185.  - Function: window-buffer &optional WINDOW
  186.      This function returns the buffer that WINDOW is displaying.  If
  187.      WINDOW is omitted, then this function returns the buffer for the
  188.      selected window.
  189.           (window-buffer)
  190.                => #<buffer windows.texi>
  191.  - Function: get-buffer-window BUFFER-OR-NAME &optional ALL-FRAMES
  192.      This function returns a window currently displaying
  193.      BUFFER-OR-NAME, or `nil' if there is none.  If there are several
  194.      such windows, then the function returns the first one in the
  195.      cyclic ordering of windows, starting from the selected window.
  196.      *Note Cyclic Window Ordering::.
  197.      The argument ALL-FRAMES controls which set of windows are
  198.      considered.  If it is non-`nil', then all windows on all frames are
  199.      considered.  Otherwise, only windows in the selected frame are
  200.      considered.
  201.  - Command: replace-buffer-in-windows BUFFER
  202.      This function replaces BUFFER with some other buffer in all
  203.      windows displaying it.  The other buffer used is chosen with
  204.      `other-buffer'.  In the usual applications of this function, you
  205.      don't care which other buffer is used; you just want to make sure
  206.      that BUFFER is no longer displayed.
  207.      This function returns `nil'.
  208. File: elisp,  Node: Displaying Buffers,  Next: Choosing Window,  Prev: Buffers and Windows,  Up: Windows
  209. Displaying Buffers in Windows
  210. =============================
  211.    In this section we describe convenient functions that choose a window
  212. automatically and use it to display a specified buffer.  These functions
  213. can also split an existing window in certain circumstances.  We also
  214. describe variables that parameterize the heuristics used for choosing a
  215. window.  *Note Buffers and Windows::, for low-level functions that give
  216. you more precise control.
  217.    Do not use the functions in this section in order to make a buffer
  218. current so that a Lisp program can access or modify it; they are too
  219. drastic for that purpose, since they change the display of buffers in
  220. windows, which is gratuitous and will surprise the user.  Instead, use
  221. `set-buffer' (*note Current Buffer::.) and `save-excursion' (*note
  222. Excursions::.), which designate buffers as current for programmed
  223. access without affecting the display of buffers in windows.
  224.  - Command: switch-to-buffer BUFFER-OR-NAME &optional NORECORD
  225.      This function makes BUFFER-OR-NAME the current buffer, and also
  226.      displays the buffer in the selected window.  This means that a
  227.      human can see the buffer and subsequent keyboard commands will
  228.      apply to it.  Contrast this with `set-buffer', which makes
  229.      BUFFER-OR-NAME the current buffer but does not display it in the
  230.      selected window.  *Note Current Buffer::.
  231.      If BUFFER-OR-NAME does not identify an existing buffer, then a new
  232.      buffer by that name is created.
  233.      Normally the specified buffer is put at the front of the buffer
  234.      list.  This affects the operation of `other-buffer'.  However, if
  235.      NORECORD is non-`nil', this is not done.  *Note The Buffer List::.
  236.      The `switch-to-buffer' function is often used interactively, as
  237.      the binding of `C-x b'.  It is also used frequently in programs.
  238.      It always returns `nil'.
  239.  - Command: switch-to-buffer-other-window BUFFER-OR-NAME
  240.      This function makes BUFFER-OR-NAME the current buffer and displays
  241.      it in a window not currently selected.  It then selects that
  242.      window.  The handling of the buffer is the same as in
  243.      `switch-to-buffer'.
  244.      The previously selected window is absolutely never used to display
  245.      the buffer.  If it is the only window, then it is split to make a
  246.      distinct window for this purpose.  If the selected window is
  247.      already displaying the buffer, then it continues to do so, but
  248.      another window is nonetheless found to display it in as well.
  249.  - Function: pop-to-buffer BUFFER-OR-NAME &optional OTHER-WINDOW
  250.      This function makes BUFFER-OR-NAME the current buffer and switches
  251.      to it in some window, preferably not the window previously
  252.      selected.  The "popped-to" window becomes the selected window.
  253.      If the variable `pop-up-frames' is non-`nil', `pop-to-buffer'
  254.      creates a new frame to display the buffer in.  Otherwise, if the
  255.      variable `pop-up-windows' is non-`nil', windows may be split to
  256.      create a new window that is different from the original window.
  257.      For details, see *Note Choosing Window::.
  258.      If OTHER-WINDOW is non-`nil', `pop-to-buffer' finds or creates
  259.      another window even if BUFFER-OR-NAME is already visible in the
  260.      selected window.  Thus BUFFER-OR-NAME could end up displayed in
  261.      two windows.  On the other hand, if BUFFER-OR-NAME is already
  262.      displayed in the selected window and OTHER-WINDOW is `nil', then
  263.      the selected window is considered sufficient display for
  264.      BUFFER-OR-NAME, so that nothing needs to be done.
  265.      If BUFFER-OR-NAME is a string that does not name an existing
  266.      buffer, a buffer by that name is created.
  267.      An example use of this function is found at the end of *Note
  268.      Filter Functions::.
  269. File: elisp,  Node: Choosing Window,  Next: Window Point,  Prev: Displaying Buffers,  Up: Windows
  270. Choosing a Window
  271. =================
  272.    This section describes the basic facility which chooses a window to
  273. display a buffer in--`display-buffer'.  All the higher-level functions
  274. and commands use this subroutine.  Here we describe how to use
  275. `display-buffer' and how to customize it.
  276.  - Function: display-buffer BUFFER-OR-NAME &optional NOT-THIS-WINDOW
  277.      This function makes BUFFER-OR-NAME appear in some window, like
  278.      `pop-to-buffer', but it does not select that window and does not
  279.      make the buffer current.  The identity of the selected window is
  280.      unaltered by this function.
  281.      If NOT-THIS-WINDOW is non-`nil', it means that the specified
  282.      buffer should be displayed in a window other than the selected
  283.      one, even if it is already on display in the selected window.
  284.      This can cause the buffer to appear in two windows at once.
  285.      Otherwise, if BUFFER-OR-NAME is already being displayed in any
  286.      window, that is good enough, so this function does nothing.
  287.      `display-buffer' returns the window chosen to display
  288.      BUFFER-OR-NAME.
  289.      Precisely how `display-buffer' finds or creates a window depends on
  290.      the variables described below.
  291.    A window can be marked as "dedicated" to its buffer.  Then
  292. `display-buffer' does not try to use that window.
  293.  - Function: window-dedicated-p WINDOW
  294.      This function returns `t' if WINDOW is marked as dedicated;
  295.      otherwise `nil'.
  296.  - Function: set-window-dedicated-p WINDOW FLAG
  297.      This function marks WINDOW as dedicated if FLAGS is non-`nil', and
  298.      nondedicated otherwise.
  299.  - User Option: pop-up-windows
  300.      This variable controls whether `display-buffer' makes new windows.
  301.      If it is non-`nil' and there is only one window, then that window
  302.      is split.  If it is `nil', then `display-buffer' does not split
  303.      the single window, but rather replaces its buffer.
  304.  - User Option: split-height-threshold
  305.      This variable determines when `display-buffer' may split a window,
  306.      if there are multiple windows.  `display-buffer' splits the
  307.      largest window if it has at least this many lines.
  308.      If there is only one window, it is split regardless of this value,
  309.      provided `pop-up-windows' is non-`nil'.
  310.  - User Option: pop-up-frames
  311.      This variable controls whether `display-buffer' makes new frames.
  312.      If it is non-`nil', `display-buffer' makes a new frame.  If it is
  313.      `nil', then `display-buffer' either splits a window or reuses one.
  314.      If this is non-`nil', the variables `pop-up-windows' and
  315.      `split-height-threshold' do not matter.
  316.      *Note Frames::, for more information.
  317.  - Variable: pop-up-frame-function
  318.      This variable specifies how to make a new frame if `pop-up-frame'
  319.      is non-`nil'.
  320.      Its value should be a function of no arguments.  When
  321.      `display-buffer' makes a new frame, it does so by calling that
  322.      function, which should return a frame.  The default value of the
  323.      variable is a function which creates a frame using parameters from
  324.      `pop-up-frame-alist'.
  325.  - Variable: pop-up-frame-alist
  326.      This variable holds an alist specifying frame parameters used when
  327.      `display-buffer' makes a new frame.  *Note Frame Parameters::, for
  328.      more information about frame parameters.
  329.  - Variable: display-buffer-function
  330.      This variable is the most flexible way to customize the behavior of
  331.      `display-buffer'.  If it is non-`nil', it should be a function
  332.      that `display-buffer' calls to do the work.  The function should
  333.      accept two arguments, the same two arguments that `display-buffer'
  334.      received.  It should choose or create a window, display the
  335.      specified buffer, and then return the window.
  336.      This hook takes precedence over all the other options and hooks
  337.      described above.
  338. File: elisp,  Node: Window Point,  Next: Window Start,  Prev: Choosing Window,  Up: Windows
  339. Window Point
  340. ============
  341.    Each window has its own value of point, independent of the value of
  342. point in other windows displaying the same buffer.  This makes it useful
  343. to have multiple windows showing one buffer.
  344.    * The window point is established when a window is first created; it
  345.      is initialized from the buffer's point, or from the window point
  346.      of another window opened on the buffer if such a window exists.
  347.    * Selecting a window sets the value of point in its buffer to the
  348.      window's value of point.  Conversely, deselecting a window sets
  349.      the window's value of point from that of the buffer.  Thus, when
  350.      you switch between windows that display a given buffer, the point
  351.      value for the selected window is in effect in the buffer, while
  352.      the point values for the other windows are stored in those windows.
  353.    * As long as the selected window displays the current buffer, the
  354.      window's point and the buffer's point always move together; they
  355.      remain equal.
  356.    * *Note Positions::, for more details on positions.
  357.    As far as the user is concerned, point is where the cursor is, and
  358. when the user switches to another buffer, the cursor jumps to the
  359. position of point in that buffer.
  360.  - Function: window-point WINDOW
  361.      This function returns the current position of point in WINDOW.
  362.      For a nonselected window, this is the value point would have (in
  363.      that window's buffer) if that window were selected.
  364.      When WINDOW is the selected window and its buffer is also the
  365.      current buffer, the value returned is the same as point in that
  366.      buffer.
  367.      Strictly speaking, it would be more correct to return the
  368.      "top-level" value of point, outside of any `save-excursion' forms.
  369.      But that value is hard to find.
  370.  - Function: set-window-point WINDOW POSITION
  371.      This function positions point in WINDOW at position POSITION in
  372.      WINDOW's buffer.
  373. File: elisp,  Node: Window Start,  Next: Vertical Scrolling,  Prev: Window Point,  Up: Windows
  374. The Window Start Position
  375. =========================
  376.    Each window contains a marker used to keep track of a buffer position
  377. which specifies where in the buffer display should start.  This position
  378. is called the "display-start" position of the window (or just the
  379. "start").  The character after this position is the one that appears at
  380. the upper left corner of the window.  It is usually, but not
  381. inevitably, at the beginning of a text line.
  382.  - Function: window-start &optional WINDOW
  383.      This function returns the display-start position of window WINDOW.
  384.      If WINDOW is `nil', the selected window is used.
  385.           (window-start)
  386.                => 7058
  387.      For a more complicated example of use, see the description of
  388.      `count-lines' in *Note Text Lines::.
  389.  - Function: window-end &optional WINDOW
  390.      This function returns the position of the end of the display in
  391.      window WINDOW.  If WINDOW is `nil', the selected window is used.
  392.  - Function: set-window-start WINDOW POSITION &optional NOFORCE
  393.      This function sets the display-start position of WINDOW to
  394.      POSITION in WINDOW's buffer.
  395.      The display routines insist that the position of point be visible
  396.      when a buffer is displayed.  Normally, they change the
  397.      display-start position (that is, scroll the window) whenever
  398.      necessary to make point visible.  However, if you specify the
  399.      start position with this function with `nil' for NOFORCE, it means
  400.      you want display to start at POSITION even if that would put the
  401.      location of point off the screen.  What the display routines do in
  402.      this case is move point instead, to the left margin on the middle
  403.      line in the window.
  404.      For example, if point is 1 and you attempt to set the start of the
  405.      window to 2, then the position of point would be "above" the top
  406.      of the window.  The display routines would automatically move
  407.      point if it is still 1 when redisplay occurs.  Here is an example:
  408.           ;; Here is what `foo' looks like before executing
  409.           ;;   the `set-window-start' expression.
  410.           
  411.           ---------- Buffer: foo ----------
  412.           -!-This is the contents of buffer foo.
  413.           2
  414.           3
  415.           4
  416.           5
  417.           6
  418.           ---------- Buffer: foo ----------
  419.           
  420.           (set-window-start
  421.            (selected-window)
  422.            (1+ (window-start)))
  423.           
  424.           ;; Here is what `foo' looks like after executing
  425.           ;;   the `set-window-start' expression.
  426.           
  427.           ---------- Buffer: foo ----------
  428.           his is the contents of buffer foo.
  429.           2
  430.           3
  431.           -!-4
  432.           5
  433.           6
  434.           ---------- Buffer: foo ----------
  435.           
  436.                => 2
  437.      However, when NOFORCE is non-`nil', `set-window-start' does
  438.      nothing if the specified start position would make point invisible.
  439.      This function returns POSITION, regardless of whether the NOFORCE
  440.      option caused that position to be overruled.
  441.  - Function: pos-visible-in-window-p &optional POSITION WINDOW
  442.      This function returns `t' if POSITION is within the range of text
  443.      currently visible on the screen in WINDOW.  It returns `nil' if
  444.      POSITION is scrolled vertically out of view.  The argument
  445.      POSITION defaults to the current position of point; WINDOW, to the
  446.      selected window.  Here is an example:
  447.           (or
  448.           (pos-visible-in-window-p
  449.            (point) (selected-window))
  450.               (recenter 0))
  451.      The `pos-visible-in-window-p' function considers only vertical
  452.      scrolling.  It returns `t' if POSITION is out of view only because
  453.      WINDOW has been scrolled horizontally.  *Note Horizontal
  454.      Scrolling::.
  455. File: elisp,  Node: Vertical Scrolling,  Next: Horizontal Scrolling,  Prev: Window Start,  Up: Windows
  456. Vertical Scrolling
  457. ==================
  458.    Vertical scrolling means moving the text up or down in a window.  It
  459. works by changing the value of the window's display-start location.  It
  460. may also change the value of `window-point' to keep it on the screen.
  461.    In the commands `scroll-up' and `scroll-down', the directions "up"
  462. and "down" refer to the motion of the text in the buffer at which you
  463. are looking through the window.  Imagine that the text is written on a
  464. long roll of paper and that the scrolling commands move the paper up
  465. and down.  Thus, if you are looking at text in the middle of a buffer
  466. and repeatedly call `scroll-down', you will eventually see the
  467. beginning of the buffer.
  468.    Some people have urged that the opposite convention be used: they
  469. imagine that the window moves over text that remains in place.  Then
  470. "down" commands would take you to the end of the buffer.  This view is
  471. more consistent with the actual relationship between windows and the
  472. text in the buffer, but it is less like what the user sees.  The
  473. position of a window on the terminal does not move, and short scrolling
  474. commands clearly move the text up or down on the screen.  We have chosen
  475. names that fit the user's point of view.
  476.    The scrolling functions (aside from `scroll-other-window') will have
  477. unpredictable results if the current buffer is different from the
  478. buffer that is displayed in the selected window.  *Note Current
  479. Buffer::.
  480.  - Command: scroll-up &optional COUNT
  481.      This function scrolls the text in the selected window upward COUNT
  482.      lines.  If COUNT is negative, scrolling is actually downward.
  483.      If COUNT is `nil' (or omitted), then the length of scroll is
  484.      `next-screen-context-lines' lines less than the usable height of
  485.      the window (not counting its mode line).
  486.      `scroll-up' returns `nil'.
  487.  - Command: scroll-down &optional COUNT
  488.      This function scrolls the text in the selected window downward
  489.      COUNT lines.  If COUNT is negative, scrolling is actually upward.
  490.      If COUNT is omitted or `nil', then the length of the scroll is
  491.      `next-screen-context-lines' lines less than the usable height of
  492.      the window.
  493.      `scroll-down' returns `nil'.
  494.  - Command: scroll-other-window &optional COUNT
  495.      This function scrolls the text in another window upward COUNT
  496.      lines.  Negative values of COUNT, or `nil', are handled as in
  497.      `scroll-up'.
  498.      The window that is scrolled is normally the one following the
  499.      selected window in the cyclic ordering of windows--the window that
  500.      `next-window' would return.  *Note Cyclic Window Ordering::.
  501.      If the selected window is the minibuffer, the next window is
  502.      normally the one at the top left corner.  However, you can specify
  503.      the window to scroll by binding the variable
  504.      `minibuffer-scroll-window'.  This variable has no effect when any
  505.      other window is selected.  *Note Minibuffer Misc::.
  506.      When the minibuffer is active, it is the next window if the
  507.      selected window is the one at the bottom right corner.  In this
  508.      case, `scroll-other-window' attempts to scroll the minibuffer.  If
  509.      the minibuffer contains just one line, it has nowhere to scroll
  510.      to, so the line reappears after the echo area momentarily displays
  511.      the message "Beginning of buffer".
  512.  - Variable: other-window-scroll-buffer
  513.      If this variable is non-`nil', it tells `scroll-other-window'
  514.      which buffer to scroll.
  515.  - User Option: scroll-step
  516.      This variable controls how scrolling is done automatically when
  517.      point moves off the screen.  If the value is zero, then the text
  518.      is scrolled so that point is centered vertically in the window.
  519.      If the value is a positive integer N, then if it is possible to
  520.      bring point back on screen by scrolling N lines in either
  521.      direction, that is done; otherwise, point is centered vertically
  522.      as usual.  The default value is zero.
  523.  - User Option: next-screen-context-lines
  524.      The value of this variable is the number of lines of continuity to
  525.      retain when scrolling by full screens.  For example, when
  526.      `scroll-up' executes, this many lines that were visible at the
  527.      bottom of the window move to the top of the window.  The default
  528.      value is `2'.
  529.  - Command: recenter &optional COUNT
  530.      This function scrolls the selected window to put the text where
  531.      point is located at a specified vertical position within the
  532.      window.
  533.      If COUNT is a nonnegative number, it puts the line containing
  534.      point COUNT lines down from the top of the window.  If COUNT is a
  535.      negative number, then it counts upward from the bottom of the
  536.      window, so that -1 stands for the last usable line in the window.
  537.      If COUNT is a non-`nil' list, then it stands for the line in the
  538.      middle of the window.
  539.      If COUNT is `nil', then it puts the line containing point in the
  540.      middle of the window, then clears and redisplays the entire
  541.      selected frame.
  542.      When `recenter' is called interactively, Emacs sets COUNT to the
  543.      raw prefix argument.  Thus, typing `C-u' as the prefix sets the
  544.      COUNT to a non-`nil' list, while typing `C-u 4' sets COUNT to 4,
  545.      which positions the current line four lines from the top.
  546.      Typing `C-u 0 C-l' positions the current line at the top of the
  547.      window.  This action is so handy that some people bind the command
  548.      to a function key.  For example,
  549.           (defun line-to-top-of-window ()
  550.             "Scroll current line to top of window.
  551.           Replaces three keystroke sequence C-u 0 C-l."
  552.             (interactive)
  553.             (recenter 0))
  554.           
  555.           (global-set-key "\C-cl" 'line-to-top-of-window)
  556. File: elisp,  Node: Horizontal Scrolling,  Next: Size of Window,  Prev: Vertical Scrolling,  Up: Windows
  557. Horizontal Scrolling
  558. ====================
  559.    Because we read English first from top to bottom and second from left
  560. to right, horizontal scrolling is not like vertical scrolling.  Vertical
  561. scrolling involves selection of a contiguous portion of text to display.
  562. Horizontal scrolling causes part of each line to go off screen.  The
  563. amount of horizontal scrolling is therefore specified as a number of
  564. columns rather than as a position in the buffer.  It has nothing to do
  565. with the display-start position returned by `window-start'.
  566.    Usually, no horizontal scrolling is in effect; then the leftmost
  567. column is at the left edge of the window.  In this state, scrolling to
  568. the right is meaningless, since there is no data to the left of the
  569. screen to be revealed by it, so it is not allowed.  Scrolling to the
  570. left is allowed; it causes the first columns of text to go off the edge
  571. of the window and can reveal additional columns on the right that were
  572. truncated before.  Once a window has a nonzero amount of leftward
  573. horizontal scrolling, you can scroll it back to the right, but only so
  574. far as to reduce the net horizontal scroll to zero.  There is no limit
  575. to how far left you can scroll, but eventually all the text will
  576. disappear off the left edge.
  577.  - Command: scroll-left COUNT
  578.      This function scrolls the selected window COUNT columns to the
  579.      left (or to the right if COUNT is negative).  The return value is
  580.      the total amount of leftward horizontal scrolling in effect after
  581.      the change--just like the value returned by `window-hscroll'.
  582.  - Command: scroll-right COUNT
  583.      This function scrolls the selected window COUNT columns to the
  584.      right  (or to the left if COUNT is negative).  The return value is
  585.      the total amount of leftward horizontal scrolling in effect after
  586.      the change--just like the value returned by `window-hscroll'.
  587.      Once you scroll a window as far right as it can go, back to its
  588.      normal position where the total leftward scrolling is zero,
  589.      attempts to scroll any farther have no effect.
  590.  - Function: window-hscroll &optional WINDOW
  591.      This function returns the total leftward horizontal scrolling of
  592.      WINDOW--the number of columns by which the text in WINDOW is
  593.      scrolled left past the left margin.
  594.      The value is never negative.  It is zero when no horizontal
  595.      scrolling has been done in WINDOW (which is usually the case).
  596.      If WINDOW is `nil', the selected window is used.
  597.           (window-hscroll)
  598.                => 0
  599.           (scroll-left 5)
  600.                => 5
  601.           (window-hscroll)
  602.                => 5
  603.  - Function: set-window-hscroll WINDOW COLUMNS
  604.      This function sets the number of columns from the left margin that
  605.      WINDOW is scrolled to the value of COLUMNS.  The argument COLUMNS
  606.      should be zero or positive; if not, it is taken as zero.
  607.      The value returned is COLUMNS.
  608.           (set-window-hscroll (selected-window) 10)
  609.                => 10
  610.    Here is how you can determine whether a given position POSITION is
  611. off the screen due to horizontal scrolling:
  612.      (save-excursion
  613.        (goto-char POSITION)
  614.        (and
  615.         (>= (- (current-column) (window-hscroll WINDOW)) 0)
  616.         (< (- (current-column) (window-hscroll WINDOW))
  617.            (window-width WINDOW))))
  618. File: elisp,  Node: Size of Window,  Next: Resizing Windows,  Prev: Horizontal Scrolling,  Up: Windows
  619. The Size of a Window
  620. ====================
  621.    An Emacs window is rectangular, and its size information consists of
  622. the height (the number of lines) and the width (the number of character
  623. positions in each line).  The mode line is included in the height.  For
  624. a window that does not abut the right hand edge of the screen, the
  625. column of `|' characters that separates it from the window on the right
  626. is included in the width.
  627.    The following three functions return size information about a window:
  628.  - Function: window-height &optional WINDOW
  629.      This function returns the number of lines in WINDOW, including its
  630.      mode line.  If WINDOW fills its entire frame, this is one less
  631.      than the value of `frame-height' on that frame (since the last line
  632.      is always reserved for the minibuffer).
  633.      If WINDOW is `nil', the function uses the selected window.
  634.           (window-height)
  635.                => 23
  636.           (split-window-vertically)
  637.                => #<window 4 on windows.texi>
  638.           (window-height)
  639.                => 11
  640.  - Function: window-width &optional WINDOW
  641.      This function returns the number of columns in WINDOW.  If WINDOW
  642.      fills its entire frame, this is the same as the value of
  643.      `frame-width' on that frame.
  644.      If WINDOW is `nil', the function uses the selected window.
  645.           (window-width)
  646.                => 80
  647.  - Function: window-edges &optional WINDOW
  648.      This function returns a list of the edge coordinates of WINDOW.
  649.      If WINDOW is `nil', the selected window is used.
  650.      The order of the list is `(LEFT TOP RIGHT BOTTOM)', all elements
  651.      relative to 0, 0 at the top left corner of the frame.  The element
  652.      RIGHT of the value is one more than the rightmost column used by
  653.      WINDOW, and BOTTOM is one more than the bottommost row used by
  654.      WINDOW and its mode-line.
  655.      Here is the result obtained on a typical 24-line terminal with
  656.      just one window:
  657.           (window-edges (selected-window))
  658.                => (0 0 80 23)
  659.      If WINDOW is at the upper left corner of its frame, RIGHT and
  660.      BOTTOM are the same as the values returned by `(window-width)' and
  661.      `(window-height)' respectively, and TOP and BOTTOM are zero.  For
  662.      example, the edges of the following window are `0 0 5 8'.
  663.      Assuming that the frame has more than 8 columns, the last column
  664.      of the window (column 7) holds a border rather than text.  The
  665.      last row (row 4) holds the mode line, shown here with `xxxxxxxxx'.
  666.                      0
  667.                      _______
  668.                   0 |       |
  669.                     |       |
  670.                     |       |
  671.                     |       |
  672.                     xxxxxxxxx  4
  673.           
  674.                             7
  675.      When there are side-by-side windows, any window not at the right
  676.      edge of its frame has a border in its last column.  This border
  677.      counts as one column in the width of the window.  A window never
  678.      includes a border on its left, since the border there belongs to
  679.      the window to the left.
  680.      In the following example, let's imagine that the frame is 7
  681.      columns wide.  Then the edges of the left window are `0 0 4 3' and
  682.      the edges of the right window are `4 0 7 3'.
  683.                      ___ ___
  684.                     |   |   |
  685.                     |   |   |
  686.                     xxxxxxxxx
  687.           
  688.                      0  34  7
  689. File: elisp,  Node: Resizing Windows,  Next: Coordinates and Windows,  Prev: Size of Window,  Up: Windows
  690. Changing the Size of a Window
  691. =============================
  692.    The window size functions fall into two classes: high-level commands
  693. that change the size of windows and low-level functions that access
  694. window size.  Emacs does not permit overlapping windows or gaps between
  695. windows, so resizing one window affects other windows.
  696.  - Command: enlarge-window SIZE &optional HORIZONTAL
  697.      This function makes the selected window SIZE lines bigger,
  698.      stealing lines from neighboring windows.  It takes the lines from
  699.      one window at a time until that window is used up, then takes from
  700.      another.  If a window from which lines are stolen shrinks below
  701.      `window-min-height' lines, then that window disappears.
  702.      If HORIZONTAL is non-`nil', then this function makes WINDOW wider
  703.      by SIZE columns, stealing columns instead of lines.  If a window
  704.      from which columns are stolen shrinks below `window-min-width'
  705.      columns, then that window disappears.
  706.      If the window's frame is smaller than SIZE lines (or columns),
  707.      then the function makes the window occupy the entire height (or
  708.      width) of the frame.
  709.      If SIZE is negative, this function shrinks the window by -SIZE
  710.      lines.  If it becomes shorter than `window-min-height', it
  711.      disappears.
  712.      `enlarge-window' returns `nil'.
  713.  - Command: enlarge-window-horizontally COLUMNS
  714.      This function makes the selected window COLUMNS wider.  It could
  715.      be defined as follows:
  716.           (defun enlarge-window-horizontally (columns)
  717.             (enlarge-window columns t))
  718.  - Command: shrink-window SIZE &optional HORIZONTAL
  719.      This function is like `enlarge-window' but negates the argument
  720.      SIZE, making the selected window smaller by giving lines (or
  721.      columns) to the other windows.  If the window shrinks below
  722.      `window-min-height' or `window-min-width', then it disappears.
  723.      If SIZE is negative, the window is enlarged by -SIZE lines.
  724.  - Command: shrink-window-horizontally COLUMNS
  725.      This function makes the selected window COLUMNS narrower.  It
  726.      could be defined as follows:
  727.           (defun shrink-window-horizontally (columns)
  728.             (shrink-window columns t))
  729.    The following two variables constrain the window size changing
  730. functions to a minimum height and width.
  731.  - User Option: window-min-height
  732.      The value of this variable determines how short a window may become
  733.      before it disappears.  A window disappears when it becomes smaller
  734.      than `window-min-height', and no window may be created that is
  735.      smaller.  The absolute minimum height is two (allowing one line
  736.      for the mode line, and one line for the buffer display).  Actions
  737.      which change window sizes reset this variable to two if it is less
  738.      than two.  The default value is 4.
  739.  - User Option: window-min-width
  740.      The value of this variable determines how narrow a window may
  741.      become before it disappears.  A window disappears when it becomes
  742.      narrower than `window-min-width', and no window may be created
  743.      that is narrower.  The absolute minimum width is one; any value
  744.      below that is ignored.  The default value is 10.
  745. File: elisp,  Node: Coordinates and Windows,  Next: Window Configurations,  Prev: Resizing Windows,  Up: Windows
  746. Coordinates and Windows
  747. =======================
  748.    This section describes how to compare screen coordinates with
  749. windows.
  750.  - Function: window-at X Y &optional FRAME
  751.      This function returns the window containing the specified cursor
  752.      position in the frame FRAME.  The coordinates X and Y are measured
  753.      in characters and count from the top left corner of the screen or
  754.      frame.
  755.      If you omit FRAME, the selected frame is used.
  756.  - Function: coordinates-in-window-p COORDINATES WINDOW
  757.      This function checks whether a particular frame position falls
  758.      within the window WINDOW.
  759.      The argument COORDINATES is a cons cell of this form:
  760.           (X . Y)
  761.      The coordinates X and Y are measured in characters, and count from
  762.      the top left corner of the screen or frame.
  763.      The value of `coordinates-in-window-p' is non-`nil' if the
  764.      coordinates are inside WINDOW.  The value also indicates what part
  765.      of the window the position is in, as follows:
  766.     `(RELX . RELY)'
  767.           The coordinates are inside WINDOW.  The numbers RELX and RELY
  768.           are the equivalent window-relative coordinates for the
  769.           specified position, counting from 0 at the top left corner of
  770.           the window.
  771.     `mode-line'
  772.           The coordinates are in the mode line of WINDOW.
  773.     `vertical-split'
  774.           The coordinates are in the vertical line between WINDOW and
  775.           its neighbor to the right.
  776.     `nil'
  777.           The coordinates are not in any sense within WINDOW.
  778.      The function `coordinates-in-window-p' does not require a frame as
  779.      argument because it always uses the frame that window WINDOW is on.
  780. File: elisp,  Node: Window Configurations,  Prev: Coordinates and Windows,  Up: Windows
  781. Window Configurations
  782. =====================
  783.    A "window configuration" records the entire layout of a frame--all
  784. windows, their sizes, which buffers they contain, what part of each
  785. buffer is displayed, and the values of point and the mark.  You can
  786. bring back an entire previous layout by restoring a window
  787. configuration previously saved.
  788.    If you want to record all frames instead of just one, use a frame
  789. configuration instead of a window configuration.  *Note Frame
  790. Configurations::.
  791.  - Function: current-window-configuration
  792.      This function returns a new object representing Emacs's current
  793.      window configuration, namely the number of windows, their sizes
  794.      and current buffers, which window is the selected window, and for
  795.      each window the displayed buffer, the display-start position, and
  796.      the positions of point and the mark.  An exception is made for
  797.      point in the current buffer, whose value is not saved.
  798.  - Function: set-window-configuration CONFIGURATION
  799.      This function restores the configuration of Emacs's windows and
  800.      buffers to the state specified by CONFIGURATION.  The argument
  801.      CONFIGURATION must be a value that was previously returned by
  802.      `current-window-configuration'.
  803.      Here is a way of using this function to get the same effect as
  804.      `save-window-excursion':
  805.           (let ((config (current-window-configuration)))
  806.             (unwind-protect
  807.                 (progn (split-window-vertically nil)
  808.                        ...)
  809.               (set-window-configuration config)))
  810.  - Special Form: save-window-excursion FORMS...
  811.      This special form executes FORMS in sequence, preserving window
  812.      sizes and contents, including the value of point and the portion
  813.      of the buffer which is visible.  It also preserves the choice of
  814.      selected window.  However, it does not restore the value of point
  815.      in the current buffer; use `save-excursion' for that.
  816.      The return value is the value of the final form in FORMS.  For
  817.      example:
  818.           (split-window)
  819.                => #<window 25 on control.texi>
  820.           (setq w (selected-window))
  821.                => #<window 19 on control.texi>
  822.           (save-window-excursion
  823.             (delete-other-windows w)
  824.             (switch-to-buffer "foo")
  825.             'do-something)
  826.                => do-something
  827.                ;; The screen is now split again.
  828.  - Function: window-configuration-p OBJECT
  829.      This function returns `t' if OBJECT is a window configuration.
  830.    Primitives to look inside of window configurations would make sense,
  831. but none are implemented.  It is not clear they are useful enough to be
  832. worth implementing.
  833. File: elisp,  Node: Frames,  Next: Positions,  Prev: Windows,  Up: Top
  834. Frames
  835. ******
  836.    A FRAME is a rectangle on the screen that contains one or more Emacs
  837. windows.  A frame initially contains a single main window (plus perhaps
  838. a minibuffer window) which you can subdivide vertically or horizontally
  839. into smaller windows.
  840.    When Emacs runs on a text-only terminal, it has just one frame, a
  841. "terminal frame".  There is no way to create another terminal frame
  842. after startup.  If Emacs has an X display, it does not make a terminal
  843. frame; instead, it initially creates a single "X window frame".  You
  844. can create more; see *Note Creating Frames::.
  845.  - Function: framep OBJECT
  846.      This predicate returns `t' if OBJECT is a frame, and `nil'
  847.      otherwise.
  848. * Menu:
  849. * Creating Frames::        Creating additional X Window frames.
  850. * Frame Parameters::        Controlling frame size, position, font, etc.
  851. * Deleting Frames::        Frames last until explicitly deleted.
  852. * Finding All Frames::        How to examine all existing frames.
  853. * Frames and Windows::        A frame contains windows;
  854.                   display of text always works through windows.
  855. * Minibuffers and Frames::    How a frame finds the minibuffer to use.
  856. * Input Focus::            What is this??
  857. * Visibility of Frames::    Frames may be visible or invisible, or icons.
  858. * Raising and Lowering::    Raising a frame makes it hide other X windows;
  859.                   lowering it makes the others hide them.
  860. * Frame Configurations::    Saving the state of all frames.
  861. * Mouse Tracking::        Getting events that say when the mouse moves.
  862. * Mouse Position::        Asking where the mouse is, or moving it.
  863. * Pop-Up Menus::        Displaying a menu for the user to select from.
  864. * X Selections::        Transferring text to and from other X clients.
  865. * X Server::
  866.    *Note Emacs Display::, for related information.
  867. File: elisp,  Node: Creating Frames,  Next: Frame Parameters,  Up: Frames
  868. Creating Frames
  869. ===============
  870.    To create a new frame, call the function `make-frame'.
  871.  - Function: make-frame ALIST
  872.      This function creates a new frame, if the display mechanism permits
  873.      creation of frames.  (An X server does; an ordinary terminal does
  874.      not.)
  875.      The argument is an alist specifying frame parameters.  Any
  876.      parameters not mentioned in ALIST default according to the value
  877.      of the variable `default-frame-alist'; parameters not specified
  878.      there either default from the standard X defaults file and X
  879.      resources.
  880.      The set of possible parameters depends in principle on what kind of
  881.      window system Emacs uses to display its the frames.  *Note X Frame
  882.      Parameters::, for documentation of individual parameters you can
  883.      specify when creating an X window frame.
  884.  - Variable: default-frame-alist
  885.      An alist specifying default values of frame parameters.  Each
  886.      element has the form:
  887.           (PARAMETER . VALUE)
  888.      If you use options that specify window appearance when you invoke
  889.      Emacs, they take effect by adding elements to
  890.      `default-frame-alist'.
  891. File: elisp,  Node: Frame Parameters,  Next: Deleting Frames,  Prev: Creating Frames,  Up: Frames
  892. Frame Parameters
  893. ================
  894.    A frame has many parameters that control how it displays.
  895. * Menu:
  896. * Parameter Access::       How to change a frame's parameters.
  897. * Initial Parameters::       Specifying frame parameters when you make a frame.
  898. * X Frame Parameters::     Individual parameters documented.
  899. * Size And Position::      Changing the size and position of a frame.
  900. File: elisp,  Node: Parameter Access,  Next: Initial Parameters,  Up: Frame Parameters
  901. Access to Frame Parameters
  902. --------------------------
  903.    These functions let you read and change the parameter values of a
  904. frame.
  905.  - Function: frame-parameters FRAME
  906.      The function `frame-parameters' returns an alist of all the
  907.      parameters of FRAME.
  908.  - Function: modify-frame-parameters FRAME ALIST
  909.      This function alters the parameters of frame FRAME based on the
  910.      elements of ALIST.  Each element of ALIST has the form `(PARM .
  911.      VALUE)', where PARM is a symbol naming a parameter.  If you don't
  912.      mention a parameter in ALIST, its value doesn't change.
  913. File: elisp,  Node: Initial Parameters,  Next: X Frame Parameters,  Prev: Parameter Access,  Up: Frame Parameters
  914. Initial Frame Parameters
  915. ------------------------
  916.    You can specify the parameters for the initial startup frame by
  917. setting `initial-frame-alist' in your `.emacs' file.
  918.  - Variable: initial-frame-alist
  919.      This variable's value is an alist of parameter values to when
  920.      creating the initial X window frame.
  921.    If these parameters specify a separate minibuffer-only frame, and
  922. you have not created one, Emacs creates one for you.
  923.  - Variable: minibuffer-frame-alist
  924.      This variable's value is an alist of parameter values to when
  925.      creating an initial minibuffer-only frame--if such a frame is
  926.      needed, according to the parameters for the main initial frame.
  927.